package br.com.affero.testewel.model.document;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.affero.testewel.model.user.User;



@Entity
@Table(name = "Document")
public class Document {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	private String path;
	
	@Column(unique = true)
	private String title;
	
	private String description;

	private long size;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idUsuario", nullable = false)
	private User user;
	
	
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date uploadedAt;
	
	public Document(Long id, String path, String title, String description, long size, Date uploadedAt) {
		super();
		this.id = id;
		this.path = path;
		this.title = title;
		this.description = description;
		this.size = size;
		this.uploadedAt = uploadedAt;
	}

	public Document(){}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getSize() {
		return size;
	}

	public void setSize(long size) {
		this.size = size;
	}
	
	public String getSizeFormated(){
		return String.valueOf(getSize());
	}

	public Date getUploadedAt() {
		return uploadedAt;
	}

	public void setUploadedAt(Date updatedAt) {
		this.uploadedAt = updatedAt;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	
	
}
